 

int analogPin = 3;   
//int dc = 1000;
int value,i;
unsigned char incomingByte;

int
getAnalogValues(double x)
{
  return  (-((81 * pow(x, 4) - 20150 * pow(x, 3) + 1546875 * pow(x, 2) - 58093750 * x) / 9375000));
}
void setup()
{
 Serial.begin(9600);
}



void loop()
{
   if (Serial.available() > 0) {
    incomingByte = Serial.read();
    value = getAnalogValues(incomingByte);
    analogWrite(analogPin, value);
    }
   
    //analogWrite(analogPin, 255);
  
  /*
  for (i=0; i<=100; i=i+5)
  {
    value = getAnalogValues(i);
    analogWrite(analogPin, value);
    delay(1000);
  }
  */
  /*
  value = (int) getAnalogValues(0);
  analogWrite(analogPin, value);
  delay(1000);
  value = (int) getAnalogValues(25);
  analogWrite(analogPin, value);
  delay(1000);
  value = (int) getAnalogValues(50);
  analogWrite(analogPin, value);
  delay(1000);
  value = (int) getAnalogValues(75);
  analogWrite(analogPin, value);
  delay(1000);
  value = (int) getAnalogValues(100);
  analogWrite(analogPin, value);
  delay(1000);
*/
  /*
  int i;
  
  for (i=0; i<256; i=i + 10)
  {
    analogWrite(analogPin, i);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
    delay(500);
  }
  
  analogWrite(analogPin, 0);
  delay(dc);
  analogWrite(analogPin, 255);
  delay(dc);
    analogWrite(analogPin, 0);
  delay(dc);
  analogWrite(analogPin, 127);
  delay(dc);
  analogWrite(analogPin, 255);
  delay(dc);
  
  analogWrite(analogPin, 0);
  delay(dc);
  analogWrite(analogPin, 64);
  delay(dc);
  analogWrite(analogPin, 127);
  delay(dc);
  analogWrite(analogPin, 255);
  delay(dc);
  */
    
}
